<?php

use yii\db\Migration;

class m210915_111731_minerva_server_group extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');
        
        /* 创建表 */
        $this->createTable('{{%minerva_server_group}}', [
            'id' => "int(11) NOT NULL AUTO_INCREMENT COMMENT '主键id'",
            'group_name' => "char(16) NOT NULL COMMENT '服务器组名称'",
            'PRIMARY KEY (`id`)'
        ], "ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='大数据系统-服务器组名称表'");
        
        /* 索引设置 */
        
        
        /* 表数据 */
        $this->insert('{{%minerva_server_group}}',['id'=>'1','group_name'=>'默认服务器组']);
        
        /* 设置外键约束 */
        $this->execute('SET foreign_key_checks = 1;');
    }

    public function down()
    {
        $this->execute('SET foreign_key_checks = 0');
        /* 删除表 */
        $this->dropTable('{{%minerva_server_group}}');
        $this->execute('SET foreign_key_checks = 1;');
    }
}

